package com.way.util;

import android.gesture.Gesture;

public class GestureLevel {
	public static final float MAX_LENGTH = 1280.0F;
	public static final float MIN_LENGTH = 500.0F;
	private static final float MAX_LEVEL = 2.8F;
	private static final float MIN_LEVEL = 2.0F;

	public static float getLevel(Gesture gesture) {
		float gestureLength = gesture.getLength();
		if (gestureLength > MAX_LENGTH)
			gestureLength = MAX_LENGTH;
		if (gestureLength < MIN_LENGTH)
			gestureLength = MIN_LENGTH;
		float level = (gestureLength - MIN_LENGTH) / (MAX_LENGTH - MIN_LENGTH);
		return MAX_LEVEL - level * (MAX_LEVEL - MIN_LEVEL);
	}
}
